package com.tuzhi.sys.jpa.repository;

import com.tuzhi.base.jpa.repository.BaseRepo;
import com.tuzhi.sys.jpa.entity.SysUserRoleEntity;
import com.tuzhi.sys.jpa.entity.pk.SysUserRolePk;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface SysUserRoleRepo extends BaseRepo<SysUserRoleEntity, SysUserRolePk> {

    int countByRoleId(Long roleId);

    @Modifying
    @Query("delete from SysUserRoleEntity where roleId=:roleId")
    int deleteByRoleId(@Param("roleId") Long roleId);

    int countByUserId(Long userId);

    @Modifying
    @Query("delete from SysUserRoleEntity where userId=:userId")
    int deleteByUserId(@Param("userId") Long userId);

}
